<?php
/////////////////////////////////////////////////////////////////////////////////////		
include "required_code.php"; 

				session_start();
				$ses_user_id =$_SESSION['ses_user_id'];
				$ses_std_id = $_SESSION['ses_std_id'];
				$concept=$_SESSION['concept'];
				$round=$_SESSION['round'];
				$ls=$_SESSION['ls'];
		if($ses_user_id <> session_id() or  $ses_std_id ==''){
		echo "Authentication failed";
		echo "<meta http-equiv='refresh' content='2;URL=index.php' />";
		}    
							/*$query2="SELECT * FROM std_progress WHERE std_id=$ses_std_id";
							$db_result2=db_query($query2);
							$result2=mysql_fetch_array($db_result2);
							//echo $result2['pretest_sts'];
								if($result2['pretest_sts']==1){
								echo "Redirecting";
								echo "<meta http-equiv='refresh' content='1;URL=progress.php' />";
							}*/
							else {
/////////////////////////////////////////////////////////////////////////////////////	
////////////////////////////UPDATE PRETEST SCORE///////////////////////////////
						$i = 1;		
						for ($i = 1; $i <= $fa_test_item; $i++){ 
							
							if($round==1)
							$query_update_pretest_score= "INSERT INTO std_fa_ans_r1(std_id,concept,test_item,test_ans,test_result) VALUES ('".$ses_std_id."','".$concept."','".$i."','".$_POST['item'][$i]."','')";
							if($round==2)
							$query_update_pretest_score= "INSERT INTO std_fa_ans_r2(std_id,concept,test_item,test_ans,test_result) VALUES ('".$ses_std_id."','".$concept."','".$i."','".$_POST['item'][$i]."','')";
							//echo $query_update_pretest_score."<br>";
							$db_query_update_pretest_score=db_query($query_update_pretest_score);
							
						}
						if($db_query_update_pretest_score){
								
								///////////////////////UPDATE PRETEST STATUS (0 -> 1) //////////////////////////			
								if($round==1)
								$query_update_ls_test_sts= "UPDATE fa_test_progress SET fa1='D' WHERE std_id='".$ses_std_id."' AND concept='".$concept."'";
								
								if($round==2)
								$query_update_ls_test_sts= "UPDATE fa_test_progress SET fa2='D' WHERE std_id='".$ses_std_id."' AND concept='".$concept."'";
								
								db_query($query_update_ls_test_sts);
									echo "Redirecting...";
									echo "<meta http-equiv='refresh' content='1;URL=fa_test_result.php' />";
								
										
								///////////////////////UPDATE PRETEST STATUS (0 -> 1) //////////////////////////
						}
				
				////////////////////////////UPDATE PRETEST SCORE///////////////////////////////
						
						
/////////////////////////////////////////////////////////////////////////////////////		
		$db_close=db_disconnect($db_open);
		}
/////////////////////////////////////////////////////////////////////////////////////		
?>